<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="admin/Hui/lib/html5.js"></script>
<script type="text/javascript" src="admin/Hui/lib/respond.min.js"></script>
<script type="text/javascript" src="admin/Hui/lib/PIE_IE678.js"></script>

<![endif]-->
<link type="text/css" rel="stylesheet" href="admin/Hui/css/H-ui.css" />
<link type="text/css" rel="stylesheet"
	href="admin/Hui/css/H-ui.admin.css" />
<link type="text/css" rel="stylesheet"
	href="admin/Hui/font/font-awesome.min.css" />
<!--[if IE 7]>
<link href="admin/Hui/font/font-awesome-ie7.min.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script type="text/javascript" src="admin/Hui/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="admin/Hui/lib/layer1.9/layer.js"></script>
<title>添加用户</title>
</head>
<body>
	<script>
		function change(status) {
			var st = document.getElementById(status);
			st.checked = "checked";
		}

		$(function() {
			$("#user_name").on(
					"blur",
					function() {
						$.post("user!checkUser.action", {
							user_name : $("#user_name").val(),
							user_id : $("#user_id").val()
						}, function(data, status) {
							if (data == 0) {
								$("#insert").bind(
										"click",
										function(event) {
											if ($("#user_name").val() != null
													&& $("#user_name").val() != "") {
												layer.msg('该用户名已存在,请重新输入');
												return false;
											}
										});
								layer.msg('该用户名已存在,请重新输入');
							}
						});
					});
			
			$("#user_phone").on(
					"blur",
					function() {
						$.post("user!checkPhone.action", {
							user_phone : $("#user_phone").val(),
							user_id : $("#user_id").val()
						}, function(data, status) {
							if (data == 0) {
								$("#insert").bind(
										"click",
										function(event) {
											if ($("#user_phone").val() != null
													&& $("#user_phone").val() != "") {
												layer.msg('该手机号码已存在,请重新输入');
												return false;
											}
										});
								layer.msg('该手机号码已存在,请重新输入');
							}
						});
					});
			
			$("#user_email").on(
					"blur",
					function() {
						$.post("user!checkEmail.action", {
							user_email : $("#user_email").val(),
							user_id : $("#user_id").val()
						}, function(data, status) {
							if (data == 0) {
								$("#insert").bind(
										"click",
										function(event) {
											if ($("#user_email").val() != null
													&& $("#user_email").val() != "") {
												layer.msg('该邮箱已存在,请重新输入');
												return false;
											}
										});
								layer.msg('该邮箱已存在,请重新输入');
							}
						});
					});
		});
	</script>
	<div class="pd-20">
		<div class="Huiform">
			<form action="user!update.action" method="post">
				<input type="hidden" name="user_pwd" value="${user_pwd }">
				<input type="hidden" name="user_id" id="user_id" value="${user_id }">
				<input type="hidden" name="user_regtime" value="${user_regtime }">
				<table class="table table-bg">
					<tbody>
						<tr>
							<th width="100" class="text-r"><span class="c-red">*</span>
								用户名：</th>
							<td><input type="text" style="width: 500px"
								class="input-text" id="user_name" name="user_name"
								value="${user_name }"> 
								
							</td>

						</tr>

						<tr>
							<th class="text-r"><span class="c-red">*</span> 性别：</th>
							<td><label> <input name="user_sex" type="radio"
									id="six_1" value="1"> 男
							</label> <label> <input type="radio" name="user_sex" value="0"
									id="six_0"> 女
							</label></td>
							<c:choose>
								<c:when test="${user_sex==1 }">
									<script>
										change('six_1');
									</script>
								</c:when>
								<c:otherwise>
									<script>
										change('six_0');
									</script>
								</c:otherwise>
							</c:choose>
						</tr>

						<tr>
							<th class="text-r"><span class="c-red">*</span> 系别：</th>
							<td><input type="text" style="width: 500px"
								class="input-text" id="user_department" name="user_department"
								datatype="*" nullmsg="系别不能为空" value="${user_department }"></td>
						</tr>

						<tr>
							<th class="text-r"><span class="c-red">*</span> 手机(长号)：</th>
							<td><input type="text" style="width: 500px" datatype="m"
								class="input-text" id="user_phone" name="user_phone"
								errormsg="手机号码输入错误！" nullmsg="手机号不能为空" value="${user_phone }"></td>
						</tr>
						<tr>
							<th class="text-r"><span class="c-red">*</span> 短号：</th>
							<td><input type="text" style="width: 500px"
								datatype="/^[0-9]{4,6}$/" class="input-text" id="user_sortphone"
								name="user_sortphone" errormsg="短号输入错误！" nullmsg="短号不能为空"
								value="${user_sortphone }"></td>
						</tr>
						<tr>
							<th class="text-r">邮箱：</th>
							<td><input type="text" style="width: 500px"
								class="input-text" id="user_email" name="user_email"
								value="${user_email }"></td>
						</tr>
						<tr>
							<th class="text-r"><span class="c-red">*</span>地址(宿舍)：</th>
							<td><input type="text" style="width: 500px"
								class="input-text" id="user_addr" name="user_addr"
								datatype="*5-6" errormsg="输入格式错误" nullmsg="地址不能为空"
								value="${user_addr }"></td>
						</tr>

						<tr>
							<th class="text-r"><span class="c-red">*</span> 积分：</th>
							<td><input type="text" style="width: 500px"
								class="input-text" id="user_scose" name="user_scose"
								datatype="n1-10" nullmsg="积分不能为空" 
								value="${user_scose }"></td>
						</tr>
						
						<tr>

							<th class="text-r"><span class="c-red">*</span> 允许登录后台：</th>
							<td><label> <input name="user_level" type="radio"
									id="yes" value="1">是
							</label> <label> <input type="radio" name="user_level" value="0"
									id="no" checked>否
							</label></td>
							<c:choose>
								<c:when test="${user_level==1 }">
									<script>
										change('yes');
									</script>
								</c:when>
								<c:otherwise>
									<script>
										change('no');
									</script>
								</c:otherwise>
							</c:choose>
						</tr>
						
						<tr>

							<th class="text-r"><span class="c-red">*</span> 允许登录前台：</th>
							<td><label> <input name="user_login" type="radio"
									id="yes" value="1">是
							</label> <label> <input type="radio" name="user_login" value="0"
									id="no" checked>否
							</label></td>
							<c:choose>
								<c:when test="${user_login==1 }">
									<script>
										change('yes');
									</script>
								</c:when>
								<c:otherwise>
									<script>
										change('no');
									</script>
								</c:otherwise>
							</c:choose>
						</tr>

						<tr>
							<th class="text-r"><span class="c-red">*</span> 角色：</th>
							<td><s:select list="roleList"
									cssStyle="position:relative;top:-40px;width: 500px;"
									cssClass="input-text" listKey="role_id" listValue="role_name"
									name="role_id">
								</s:select>
							</td>
						</tr>

						<tr>
							<th></th>
							<td><button style="position: relative; top: -20px;"
									class="btn btn-success radius" type="submit" id="insert">
									<i class="icon-ok"></i> 确定
								</button>
								<a href="javascript:window.history.back(-1);" style="position: relative; top: -20px;"
									class="btn btn-secondary radius" id="insert">
									<i class="icon-ok"></i> 返回
								</a>
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
	<script type="text/javascript" src="admin/Hui/lib/jquery.min.js"></script>
	<script type="text/javascript" src="admin/Hui/lib/Validform_v5.3.2.js"></script>
	<script type="text/javascript" src="admin/Hui/js/H-ui.js"></script>
	<script type="text/javascript" src="admin/Hui/js/H-ui.admin.js"></script>
	<script type="text/javascript">
		$(".Huiform").Validform();
	</script>


</body>
</html>